cmake_minimum_required (VERSION 3.5)

find_package(PhysFS REQUIRED)
MARK_AS_ADVANCED(PHYSFS_LIBRARY PHYSFS_INCLUDE_DIR)
if(ENABLE_NLS)
	find_package (Intl REQUIRED)
endif()
find_package(Sodium 1.0.13 REQUIRED)

file(GLOB HEADERS "*.h")
file(GLOB SRC "*.cpp")

if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
	list(APPEND SRC "cocoa_wrapper.mm")
endif()

add_library(framework STATIC ${HEADERS} ${SRC})
set_property(TARGET framework PROPERTY FOLDER "lib")
if(WZ_TARGET_ADDITIONAL_PROPERTIES)
	SET_TARGET_PROPERTIES(framework PROPERTIES ${WZ_TARGET_ADDITIONAL_PROPERTIES})
endif()
target_link_libraries(framework PUBLIC ${PHYSFS_LIBRARY} unofficial-sodium::sodium)
target_link_libraries(framework PRIVATE microecc utf8proc)
if(ENABLE_NLS)
	target_include_directories(framework PRIVATE "${Intl_INCLUDE_DIRS}")
	target_link_libraries(framework PUBLIC ${Intl_LIBRARIES})
endif()
target_include_directories(framework PUBLIC "${PHYSFS_INCLUDE_DIR}" "${CMAKE_SOURCE_DIR}/3rdparty")
target_compile_definitions(framework PRIVATE "YY_NO_UNISTD_H")
target_compile_definitions(framework PUBLIC "JSON_USE_IMPLICIT_CONVERSIONS=0")
if(MSVC)
	target_compile_definitions(framework PUBLIC "_CRT_SECURE_NO_WARNINGS")
endif()
